#include "queue.h"

void queue_init(queue_t * q, unsigned char *ptr, unsigned char len)
{
	q->pbuffer = ptr;
	q->size = len;
	q->head = (q)->tail = 0;
}

void queue_enque(queue_t * q, unsigned char e)
{
	q->pbuffer[q->head++] = e;
	if(q->head >= q->size)
	{
		q->head = 0;
	}
}



unsigned char queue_deque(queue_t * q)
{
	unsigned char e;
	
	e = q->pbuffer[q->tail++];
	if(q->tail >= q->size)
	{
		q->tail = 0;
	}
	return e;
}